<template>
  <div
    class="app-container"
    style="background-color: #ffffff;
    width: 92%;
    border-radius: 5px;
    height: 95%;
    margin: 20px auto;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;"
  >
    <div style="background-color: rgba(249, 249, 249, 1);width: 100%;height: 60px;">
      <span
        style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-style: normal;font-size: 16px;text-align: left;line-height: 20px;position: absolute;margin: 20px;"
      >法庭设备管理</span>
      <el-button
        style="margin: 16px;float: right;height: 35px;"
        type="primary"
        icon="el-icon-circle-plus-outline"
        size="mini"
        @click="handleAdd"
      >新增法庭设备</el-button></div>
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" :inline="true" label-width="100px">
      <el-form-item label="" prop="tribunalName">
        <el-select v-model="queryParams.courtCode" :disabled="disabled" filterable placeholder="请选择法院" @change="selectTribunalByCourtCode">
          <el-option
            v-for="item in options"
            :key="item.courtCode"
            :label="item.courtName"
            :value="item.courtCode"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="tribunalName">
        <el-select v-model="queryParams.tribunalCode" :disabled="false" clearable filterable placeholder="请选择法庭" @change="getList">
          <el-option
            v-for="item in TribunalOptions"
            :key="item.tribunalCode"
            :label="item.tribunalName"
            :value="item.id"
          />
        </el-select>
        <!-- <el-input
          v-model="form.tribunalName"
          placeholder="请输入法庭名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
      </el-form-item>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>
    <el-table v-loading="loading" :data="trialList" :default-sort="defaultSort" @selection-change="handleSelectionChange" @sort-change="handleSortChange" @row-dblclick="handleRowClick">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column v-if="false" label="id" align="center" prop="id" sortable="custom" :sort-orders="['descending', 'ascending']" />
      <el-table-column v-if="false" label="法院代码" align="center" prop="courtCode" />
      <el-table-column label="法院名称" align="center" prop="courtName" />
      <el-table-column label="设备名称" align="center" prop="name" />
      <el-table-column label="法庭名称" align="center" prop="tribunalName" sortable="custom" :sort-orders="['descending', 'ascending']" />
      <el-table-column v-if="false" label="法庭编号" align="center" prop="tribunalCode" />
      <el-table-column v-if="false" label="组件id" align="center" prop="equiqmentId" />
      <el-table-column label="处理引擎" align="center" prop="equipmentName" />
      <el-table-column label="厂家" align="center" prop="brand" />
      <el-table-column label="音频处理器ip" align="center" prop="ip" />
      <el-table-column label="端口" align="center" prop="port" />
      <el-table-column v-if="false" label="开指令" align="center" prop="openCommand" />
      <el-table-column v-if="false" label="开指令" align="center" prop="closeCommand" />
      <el-table-column v-if="false" label="其他指令" align="center" prop="otherCommand" />
      <el-table-column label="设备状态" align="center" :formatter="replaceStr" prop="equipmentStatus" />
      <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 修改/新增设备信息 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="设备名称" prop="brand">
          <el-input v-model="form2.name" placeholder="请输入名称" />
        </el-form-item>
        <el-form-item label="法庭" prop="tribunalCode">
          <el-select v-model="form2.tribunalCode" :disabled="false" clearable filterable placeholder="请选择法庭">
            <el-option
              v-for="item in TribunalOptions"
              :key="item.tribunalCode"
              :label="item.tribunalName"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="设备处理引擎" prop="tribunalCode">
          <el-cascader v-model="equipmentIds" :options="equipmentBrandList" clearable placeholder="请选择处理引擎" :show-all-levels="false" @change="handleChange" />
          <!-- <el-select v-model="form2.equipmentId" :disabled="false" clearable filterable placeholder="请选择设备">
            <el-option
              v-for="item in equipmentBrandList"
              :key="item.tribunalCode + 'equipmentBrand'"
              :label="item.name"
              :value="item.id"
            />
          </el-select> -->
        </el-form-item>
        <el-form-item label="ip" prop="brand">
          <el-input v-model="form2.ip" placeholder="请输入ip地址" />
        </el-form-item>
        <el-form-item label="端口" prop="brand">
          <el-input v-model="form2.port" placeholder="请输入端口" />
        </el-form-item>
        <el-form-item label="视频地址" prop="brand">
          <el-input v-model="form2.videoUrl" placeholder="请输入视频地址" />
        </el-form-item>
        <el-form-item label="庭审主机内存" prop="brand">
          <el-input v-model="form2.memory" placeholder="请输入内存" />
        </el-form-item>
        <el-form-item label="设备状态" prop="brand">
          <el-select v-model="form2.equipmentStatus" :disabled="false" clearable filterable placeholder="请选择设备状态">
            <el-option
              v-for="item in equipmentStatusList"
              :key="item.value + 'audio'"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="设备开命令" prop="brand">
          <el-input v-model="form2.openCommand" placeholder="请输入命令" />
        </el-form-item>
        <el-form-item label="设备关命令" prop="brand">
          <el-input v-model="form2.closeCommand" placeholder="请输入命令" />
        </el-form-item>
        <el-form-item label="设备其他命令" prop="brand">
          <el-input v-model="form2.otherCommand" placeholder="请输入命令" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="save">保 存</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 编辑时序 -->
    <el-dialog title="编辑时序" :visible.sync="open2" width="900px" append-to-body :close-on-click-modal="false">
      <el-table :data="tableData" style="width: 100%" @cell-click="handleEdit">
        <template v-for="(item, index) in columData">
          <el-table-column :key="index" :label="item.label" :prop="item.prop">
            <template slot-scope="scope">
              <el-input
                v-if="
                  item.edit == true && 'flag' + item.prop + scope.row.index == value
                "
                ref="flag"
                v-model="scope.row[scope.column.property]"
                @blur="blur"
              />
              <span v-else>{{ scope.row[scope.column.property] }} </span>
            </template>
          </el-table-column>
        </template>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="save2">保 存</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 编辑时序 -->
    <el-dialog title="编辑话筒通道名称" :visible.sync="open3" width="900px" append-to-body :close-on-click-modal="false">
      <el-table :data="tableData3" style="width: 100%" @cell-click="handleEdit">
        <template v-for="(item, index) in columData">
          <el-table-column :key="index" :label="item.label" :prop="item.prop">
            <template slot-scope="scope">
              <el-input
                v-if="
                  item.edit == true && 'flag' + item.prop + scope.row.index == value
                "
                ref="flag"
                v-model="scope.row[scope.column.property]"
                @blur="blur"
              />
              <span v-else>{{ scope.row[scope.column.property] }} </span>
            </template>
          </el-table-column>
        </template>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="save3">保 存</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { selectTribunalByCourtCode } from '@/api/tribunal'
import { selectTribunalEquipmentList, updateTribunalEquipment, addTribunalEquipment, deleteTribunalEquipment } from '@/api/tribunalEquipment'
import { getAllTribunalEquipmentBrandListByAssembly } from '@/api/tribunalEquipmentBrand'

import { listCourt } from '@/api/court'
import { findAllPowerConfig, updatePowerConfig, addPowerConfig } from '@/api/powerConfig'
export default {
  name: 'Audio',
  data() {
    return {
      equipmentIds: [],
      disabled: false,
      codeNum: '',
      // 遮罩层
      loading: true,
      loading2: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 案件表格数据
      trialList: [],
      burnList: [],
      // 弹出层标题
      title: '',
      title2: '',
      // 是否显示弹出层
      open: false,
      open2: false,
      open3: false,
      // 默认排序
      defaultSort: { prop: 'caseName', order: 'ascending' },
      judge: [],
      secretary: [],
      courtCode: '',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        courtCode: null,
        tribunalName: null,
        caseName: null,
        number: null,
        type: null,
        action: null,
        dept: null,
        party: null,
        chiefJudger: null,
        undertakerNumber: null,
        judge: '',
        judgeNumber: null,
        beginTime: null,
        clerkName: '',
        clerkNumber: null,
        tribunalCode: null,
        isDel: null
      },
      // 表单参数
      form2: {},
      // 表单参数
      form: {},
      options: [],
      TribunalOptions: [],
      equipmentBrandList: [],
      /** 设备状态 */
      equipmentStatusList: [
        {
          label: '启用',
          value: '1'
        },
        {
          label: '禁用',
          value: '2'
        }, {
          label: '损坏',
          value: '3'
        }
      ],
      // 表单校验
      rules: {
        caseName: [
          { required: true, message: '案号不能为空', trigger: 'blur' }
        ]
      },
      columData: [
        {
          label: '名称',
          prop: 'name',
          edit: true
        },
        {
          label: '命令',
          prop: 'command',
          edit: true
        },
        {
          label: '编号',
          prop: 'sort'
        }
      ],
      tableData: [
        {
          index: 0,
          sort: 1,
          name: '第一路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 1,
          sort: 2,
          name: '第二路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 2,
          sort: 3,
          name: '第三路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 3,
          sort: 4,
          name: '第四路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 4,
          sort: 5,
          name: '第五路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 5,
          sort: 6,
          name: '第六路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 6,
          sort: 7,
          name: '第七路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 8,
          name: '第八路电源',
          equipmentId: 2,
          command: null,
          id: null
        }
      ],
      tableData1: [
        {
          index: 0,
          sort: 1,
          name: '第一路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 1,
          sort: 2,
          name: '第二路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 2,
          sort: 3,
          name: '第三路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 3,
          sort: 4,
          name: '第四路电源',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 4,
          sort: 5,
          name: '第五路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 5,
          sort: 6,
          name: '第六路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 6,
          sort: 7,
          name: '第七路电源',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 8,
          name: '第八路电源',
          equipmentId: 2,
          command: null,
          id: null
        }
      ],
      tableData2: [
        {
          index: 0,
          sort: 1,
          name: '第一路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 1,
          sort: 2,
          name: '第二路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 2,
          sort: 3,
          name: '第三路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 3,
          sort: 4,
          name: '第四路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 4,
          sort: 5,
          name: '第五路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 5,
          sort: 6,
          name: '第六路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 6,
          sort: 7,
          name: '第七路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 8,
          name: '第八路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 8,
          sort: 9,
          name: '第九路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 9,
          sort: 10,
          name: '第十路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 10,
          sort: 11,
          name: '第十一路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 11,
          sort: 12,
          name: '第十二路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        },
        {
          index: 12,
          sort: 13,
          name: '第十三路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 13,
          sort: 14,
          name: '第十四路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 14,
          sort: 15,
          name: '第十五路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }, {
          index: 15,
          sort: 16,
          name: '第十六路电源',
          equipmentId: 2,
          switchStatus: 1,
          command: null,
          id: null
        }
      ],
      tableData3: [
        {
          index: 0,
          sort: 1,
          name: '通道一',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 1,
          sort: 2,
          name: '通道二',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 2,
          sort: 3,
          name: '通道三',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 3,
          sort: 4,
          name: '通道四',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 4,
          sort: 5,
          name: '通道五',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 5,
          sort: 6,
          name: '通道六',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 6,
          sort: 7,
          name: '通道七',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 8,
          name: '通道八',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 9,
          name: '通道九',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 10,
          name: '通道十',
          equipmentId: 2,
          command: null,
          id: null
        }
      ],
      tableData4: [
        {
          index: 0,
          sort: 1,
          name: '通道一',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 1,
          sort: 2,
          name: '通道二',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 2,
          sort: 3,
          name: '通道三',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 3,
          sort: 4,
          name: '通道四',
          equipmentId: 2,
          command: null,
          id: null
        },
        {
          index: 4,
          sort: 5,
          name: '通道五',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 5,
          sort: 6,
          name: '通道六',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 6,
          sort: 7,
          name: '通道七',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 7,
          sort: 8,
          name: '通道八',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 8,
          sort: 9,
          name: '通道九',
          equipmentId: 2,
          command: null,
          id: null
        }, {
          index: 9,
          sort: 10,
          name: '通道十',
          equipmentId: 2,
          command: null,
          id: null
        }
      ],
      value: ''
    }
  },
  created() {
    this.getAllTribunalEquipmentBrandList()
    this.getCourtList()
  },
  methods: {
    handleEdit(row, e) {
      this.value = 'flag' + e.property + row.index
      this.$nextTick(() => {
        if (this.$refs.flag[0]) {
          this.$refs.flag[0].focus()
        }
      })
    },
    blur() {
      this.value = ''
    },
    findAllPowerConfig(row) {
      findAllPowerConfig(row).then(response => {
        if (response.data.length > 0) {
          this.tableData = response.data
        } else {
          var str = row.equipmentId
          str = str.split(',')
          var num2 = str[1] - 0
          this.tableData = []
          if (num2 === 111) {
            this.tableData = JSON.parse(JSON.stringify(this.tableData2))
          } else {
            this.tableData = JSON.parse(JSON.stringify(this.tableData1))
          }
          this.tableData.forEach((item, index) => {
            item.equipmentId = row.id
          })
        }
      })
    },
    findAllAudiofig(row) {
      findAllPowerConfig(row).then(response => {
        if (response.data.length > 0) {
          this.tableData3 = response.data
        } else {
          this.tableData3 = []
          this.tableData3 = JSON.parse(JSON.stringify(this.tableData4))
          this.tableData3.forEach((item, index) => {
            item.equipmentId = row.id
          })
        }
      })
    },
    updatePowerConfig() {
      updatePowerConfig(this.tableData).then(response => {
        if (response.code === 200) {
          this.open2 = false
          this.open3 = false
          this.$message({ message: '修改成功', type: 'success' })
        }
      })
    },
    updatePowerConfig3() {
      updatePowerConfig(this.tableData3).then(response => {
        if (response.code === 200) {
          this.open2 = false
          this.open3 = false
          this.$message({ message: '修改成功', type: 'success' })
        }
      })
    },
    addPowerConfig() {
      addPowerConfig(this.tableData).then(response => {
        if (response.code === 200) {
          this.$message({ message: '添加成功', type: 'success' })
        }
      })
    },
    save2() {
      this.updatePowerConfig()
    },
    save3() {
      this.updatePowerConfig3()
    },
    handleRowClick(row) {
      var str = row.equipmentId
      str = str.split(',')
      var num1 = str[0]
      var num2 = str[1]
      if (num1 === '6') {
        if (num2 === '111') {
          this.tableData = JSON.parse(JSON.stringify(this.tableData2))
        } else {
          this.tableData = JSON.parse(JSON.stringify(this.tableData1))
        }
        this.findAllPowerConfig(row)
        this.open2 = true
      } else if (num1 === '4') {
        this.findAllAudiofig(row)
        this.open3 = true
      }
    },
    formatTreeDate(data) {
      var str = data.equipmentId
      console.log(str)
      str = str.split(',')
      var num1 = str[0] - 0
      var num2 = str[1] - 0
      this.equipmentIds = JSON.parse(JSON.stringify([num1, num2]))
      console.log('*******' + this.equipmentIds)
    },
    handleChange(value) {
      if (value) {
        this.form2.equipmentId = value[0] + ',' + value[1]
      }
      console.log(value)
    },
    /** 格式化 */
    replaceStr(row, column) {
      if (row.equipmentStatus === '1') {
        return '启用'
      } else if (column === '2') {
        return '禁用'
      } else if (column === '3') {
        return '损坏'
      }
    },
    /** 查询设备信息 */
    getAllTribunalEquipmentBrandList() {
      getAllTribunalEquipmentBrandListByAssembly().then(response => {
        this.equipmentBrandList = response.data
      })
    },
    // 根据法院代码查询法庭信息
    selectTribunalByCourtCode() {
      selectTribunalByCourtCode(this.queryParams.courtCode).then(response => {
        this.TribunalOptions = response.data
      })
    },
    /** 查询法院列表 */
    getCourtList() {
      listCourt().then(response => {
        this.options = response.data.clist
        this.queryParams.courtCode = response.data.courtCode
        if (this.options.length <= 1) {
          this.disabled = true
        }
        this.selectTribunalByCourtCode()
        this.getList()
      })
    },

    // 排序
    handleSortChange(column, prop, order) {
      this.queryParams.orderByColumn = column.prop
      this.queryParams.isAsc = column.order
      this.getList()
    },
    /** 查询法庭列表 */
    getList() {
      this.loading = true
      selectTribunalEquipmentList(this.queryParams).then(response => {
        this.trialList = []
        this.trialList = response.data.tcList.records
        this.total = response.data.tcList.total
        this.loading = false
      })
    },
    // 删除
    handleDelete(row) {
      deleteTribunalEquipment(row).then(response => {
        this.$message({ message: '删除成功', type: 'success' })
        this.getList()
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    cancel2() {
      this.open2 = false
      this.open3 = false
      this.reset()
      this.burnList = []
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        courtCode: null,
        caseName: null,
        trialNum: null,
        tribunalName: null,
        tribunalCode: null,
        number: null,
        type: null,
        action: null,
        dept: null,
        party: null,
        undertaker: null,
        undertakerNumber: null,
        judge: null,
        judgeNumber: null,
        clerk: null,
        clerkNumber: null,
        createBy: null,
        updateBy: null,
        createTime: null,
        updateTime: null,
        remark: null,
        isDel: null
      }
      this.resetForm('form')
    },
    // 表单重置
    reset2() {
      this.form2 = {
        id: null,
        name: null,
        tribunalCode: null,
        courtCode: null,
        videoUrl: null,
        ip: null,
        url: null,
        monitorType: null,
        brand: null
      }
      this.equipmentIds = []
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.queryParams.tribunalName = this.form.tribunalName
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.reset()
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset2()
      this.open = true
      this.title = '添加法庭设备信息'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset2()
      this.formatTreeDate(row)
      console.log(JSON.stringify(row))
      this.form2 = row
      this.open = true
      this.title = '修改法庭设备信息'
    },
    save() {
      if (this.form2.id != null) {
        updateTribunalEquipment(this.form2).then(response => {
          this.$message({ message: '修改成功', type: 'success' })
          this.open = false
          this.getList()
        })
      } else {
        this.form2.courtCode = this.queryParams.courtCode
        addTribunalEquipment(this.form2).then(response => {
          this.$message({ message: '保存成功', type: 'success' })
          this.open = false
          this.getList()
        })
      }
    },
    resetForm() {
      this.queryParams.caseName = ''
      this.queryParams.ktdd = ''
      this.queryParams.clerk = ''
      this.queryParams.judge = ''
      this.queryParams.beginTime = ''
    }
  }
}
</script>
<style lang="scss" scoped>
.btn{
  width: 10px;
  height: 10px;
  background-image: url("../../assets/imgs/u749.png");
}
::v-deep .el-input__inner {
  height: 32px;
}
</style>
